package org.lixue.common.util;


import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
    public static String md5(String... args) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            String[] argArr = args;
            int i = args.length;

            for (int var3 = 0; var3 < i; ++var3) {
                String arg = argArr[var3];
                md5.update(arg.getBytes("UTF-8"));
            }

            byte[] bytes = md5.digest();
            StringBuilder md5StrBuff = new StringBuilder();

            for (i = 0; i < bytes.length; ++i) {
                if (Integer.toHexString(255 & bytes[i]).length() == 1) {
                    md5StrBuff.append("0").append(Integer.toHexString(255 & bytes[i]));
                } else {
                    md5StrBuff.append(Integer.toHexString(255 & bytes[i]));
                }
            }

            return md5StrBuff.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        return null;
    }
}